﻿$(document).ready(function () {
    Account_login_yz();
    Tel_Login_yz();
    Reset_first_yz();
    Reset_next_verify();
    Reset_final_verify();
});

//ajax 跳转
function check() {
    var username = 1;
    var password = 2;
    //console.log(username);
    $.ajax({
        url: "{:U('Login/check')}",
        type: "POST",
        data: { username: username, password: password },
        //dataType: "json",
        success: function (result) {
            console.log(result);
            if (result == 1) {
                //window.location="admin.php/Index/index";
                //window.location = "{:U('Index/index')}";
                alert(1);
            } else {
                alert("用户名或密码错误");
            }
        }
    })
}
//登入验证
function Account_login_yz() {
    Account_login.bind('input propertychange', function () {
        if (!Account_account.val() == '' && !Account_password.val() == '') {
            Account_submit.removeClass("btn-disable").removeAttr("disabled", false);
        } else {
            Account_submit.addClass("btn-disable").attr("disabled", "disabled");
        }
    })
}
//密码验证 
function Tel_Login_yz() {
    Tel_login.bind('input propertychange', function () {
        var Tel_account_value = document.getElementById("tel").value;
        if (Tel_verify.val().length > 4  && (/^1(3|4|5|7|8)\d{9}$/.test(Tel_account_value))) {  //改
            Tel_countdown.removeAttr("disabled", false);//改
        } 
        else {
            Tel_countdown.attr("disabled", "disabled");//改
        }
        if (!Tel_account.val() == ''&&  (/^1(3|4|5|7|8)\d{9}$/.test(Tel_account_value)) && !Tel_verify.val() == '' && !Tel_yz.val() == '') {
            Tel_submit.removeClass("btn-disable").removeAttr("disabled", false);
        } else {
            Tel_submit.addClass("btn-disable").attr("disabled", "disabled");
        }
    })
    Tel_account.blur(function () {
        var Tel_account_value = document.getElementById("tel").value;
        if (!(/^1(3|4|5|7|8)\d{9}$/.test(Tel_account_value))) {
            $(this).parent().addClass("field-error");
            Tel_error.show().children("p").text("请输入正确的手机号码");
            return false;
        }
        Tel_error.hide();
        $(this).parent().removeClass("field-error");
        return true;
    })
}
//找回密码 第一部
function Reset_first_yz() {
    Reset_first.bind('input propertychange',function () {
        if (!Reset_first_account.val() == '' && !Reset_first_verify.val() == '') {
            Reset_first_submit.removeClass("btn-disable").removeAttr("disabled", false);
        } else {
            Reset_first_submit.addClass("btn-disable").attr("disabled", "disabled");
        }
    })
    Reset_first_form.submit(function () {
      
    })
}
//找回密码 第二部
function Reset_next_verify() {
    Reset_next.bind('input propertychange', function () {
        if (!Reset_next_yz.val() == '') {
            Reset_next_submit.removeClass("btn-disable").removeAttr("disabled", false);
        } else {
            Reset_next_submit.addClass("btn-disable").attr("disabled", "disabled");
        }
    })
}
//找回密码 第三部
function Reset_final_verify() {
    Reset_final.bind('input propertychange', function () {
        if (!Reset_final_password.val() == '') {
            Reset_final_submit.removeClass("btn-disable").removeAttr("disabled", false);
        } else {
            Reset_final_submit.addClass("btn-disable").attr("disabled", "disabled");
        }
    })
}

var Account_login = $("#Account_Login");
var Account_form = Account_login.children("form");
var Account_account = Account_form.find($("#account"));
var Account_password = Account_form.find($("#password"));
var Account_submit = Account_form.find($(".login"));
var Account_error = Account_form.find($(".error-field"));

var Tel_login = $("#Tel_Login");
var Tel_form = Tel_login.children("form");
var Tel_account = Tel_form.find($("#tel"));
var Tel_yz = Tel_form.find($("#yz"));
var Tel_verify = Tel_form.find($("#verify"));
var Tel_submit = Tel_form.find($(".login"));
var Tel_error = Tel_form.find($(".error-field"));
var Tel_countdown = Tel_form.find("#CountDown60");

var Reset_first = $("#Reset_first");
var Reset_first_form = Reset_first.children("form");
var Reset_first_account = Reset_first_form.find($("#account"));
var Reset_first_verify = Reset_first_form.find($("#verify"));
var Reset_first_submit = Reset_first_form.find($(".login"));
var Reset_first_error = Reset_first_form.find($(".error-field"));

var Reset_next = $("#Reset_next");
var Reset_next_form = Reset_next.children("form");
var Reset_next_yz = Reset_next_form.find($("#yz"));
var Reset_next_submit = Reset_next_form.find($(".login"));
var Reset_next_error = Reset_next_form.find($(".error-field"));

var Reset_final = $("#Reset_final");
var Reset_final_form = Reset_final.children("form");
var Reset_final_password = Reset_final_form.find($("#password"));
var Reset_final_submit = Reset_final_form.find($(".login"));
var Reset_final_error = Reset_final_form.find($(".error-field"));
